package com.bby.disk.bean;

import com.bby.common.model.Permission;
import com.bby.disk.manager.mfile.MPath;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.io.File;
import java.io.Serializable;
@Data
@ToString
@Accessors(chain = true)
public class MFileInfo implements Serializable {
    @MongoId
    private String id;
    private String owner;
    private String filename,md5;
    private Permission permission;
    private long createTime,lastModified,size;
    private boolean file;

    public MFileInfo() {
    }

    public MFileInfo(File file){
        filename=file.getName();
        lastModified=file.lastModified();
        size=file.length();
        this.file=file.isFile();
    }
    public MFileInfo(MPath file){
        filename=file.getName();
    }
    public MFileInfo(String name) {
        filename=name;
        file=false;
    }

}
